<template>
    <div class="container">
        <!-- 数据大屏展示区域 -->
        <div class="box" ref="box">
            <!-- 顶部导航区 -->
            <Top/>
            <!-- 底部内容展示区 -->
            <div class="bottom">
                <!-- 左 -->
                <div class="left">
                    <Tourist></Tourist>
                    <Sex></Sex>
                    <Age></Age>
                </div>
                <!-- 中 -->
                <div class="center">
                    <Map></Map>
                    <Line></Line>

                </div>
                <!-- 右 -->
                <div class="right">
                    <Rank></Rank>
                    <Year></Year>
                    <Couner></Couner>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang='ts'>
import { onMounted, ref } from 'vue';
import Top from './components/top/index.vue'
import Tourist from './components/tourist/index.vue'
import Sex from './components/sex/index.vue'
import Age from './components/age/index.vue'

import Map from './components/map/index.vue'
import Line from './components/line/index.vue'

import Rank from './components/rank/index.vue'
import Year from './components/year/index.vue'
import Couner from './components/couner/index.vue'
 
    //计算自适应
    //创建实例
    let box=ref()
    //组件挂载后实现
    onMounted(()=>{
       box.value.style.transform=`scale(${getScale()}) translate(-50%, -50%)`
        
    })
    //定义大屏缩放比例
    const getScale=(w=1920,h=1080)=>{
        const ww=window.innerWidth/w
        const wh=window.innerHeight/h
        return ww < wh ? ww : wh
    }
    //监听窗口视图变化，并实时更新比例
    window.onreset=()=>{
        box.value.style.transform=`scale(${getScale()}) translate(-50% ,-50%)`
    }


</script>

<style scoped lang='scss'>
.container{
    width: 100vw;
    height: 100vh;
    background: url('./images/bg.png') no-repeat;
    background-size: cover;
    .box{
        position: fixed;
        width: 1920px;
        height: 1080px;
        left: 50%;
        top: 50%;
        transform-origin: left top;
        .bottom{
            width: 100%;
            display: flex;
            gap: 20px;
            .left{
                flex: 1.5;
                height: 1040px;
                display: flex;
                gap: 15px;
                flex-direction: column;
                
            }
            .center{
                flex: 3;
                display: flex;
                flex-direction: column;
            }
            .right{
                flex: 1.5;
                height: 1040px;
                display: flex;
                gap: 15px;
                flex-direction: column;
            }
        }
    }
}
    
</style>